package com.qf.config;

import com.google.inject.internal.BindingBuilder;
import com.qf.consants.RabbitMQConstants;
import org.springframework.amqp.core.Binding;
import org.springframework.amqp.core.FanoutExchange;
import org.springframework.amqp.core.Queue;
import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.Configuration;

@Configuration
public class RabbitMQConfig {

    @Bean
    public FanoutExchange emailExchange(){
        return new FanoutExchange(RabbitMQConstants.EMAIL_EXCAHNGE,true,false);
    }

    @Bean
    public Queue emailQueue(){
        return new Queue(RabbitMQConstants.EMAIL_QUEUE,true,false,false);
    }

    @Bean
    public Binding emailQueueToemailExchange(){
        return org.springframework.amqp.core.BindingBuilder.bind(emailQueue()).to(emailExchange());
    }
}
